# -*- coding:utf-8 -*-
import MySQLdb
import MySQLdb.cursors
def operate_mysql(sql):
	conn = MySQLdb.connect(host='192.168.0.64', user='root',passwd='111111', db='spider_test', port = 3306,charset='utf8')	                     
	cur = conn.cursor()
	cur.execute(sql)
	conn.commit()
	cur.close()
	conn.close()
def query_from_mysql(sql):
	conn = MySQLdb.connect(host='192.168.0.64', user='root',passwd='111111', db='spider_online', port = 3306,charset='utf8')
	cur = conn.cursor()
	# urls=[]
	try:
		cur.execute(sql)
		results=cur.fetchall()
		# for row in results:
		# 	url=row[0]
		# 	urls.append(url)
	except Exception as e:
		raise
	cur.close()
	conn.close()
	return results
